/*
day317 
2020.7.10 
*/
#include<iostream>
#include<vector>
using namespace std;

 
class Solution {
public:
    int numSubarrayBoundedMax(vector<int>& A, int L, int R) {
		return count(A, R) - count(A, L-1);
    }
    
    int count(vector<int> A, int bound) {
        int ans = 0, cur = 0;
        for (int x: A) {
            cur = x <= bound ? cur + 1 : 0;
            ans += cur;
        }
        return ans;
    }
};


    

int main()
{
	vector<int> vec={2,1,4,3};
	Solution s;
	cout<<s.numSubarrayBoundedMax(vec,2,3)<<endl;
	return 0;
 } 
